<template>
    <div>
        <nav class="nav">
            <ul>
                <li>
                    <span 
                        @click="close"
                    class="iconfont icon-bottom-arrow"></span>
                </li>
                <li>
                    <span @click="addClick(0,'bookDetails')" :class="index == 0 ? 'active':''">详情</span>

                    <span @click="addClick(1,'play')" :class="index == 1 ? 'active':''">播放</span>

                    <span @click="addClick(2,'manuscript')" :class="index == 2 ? 'active':''">文稿</span>
                </li>
                <li>
                    <span class="iconfont icon-share"></span>
                </li>
            </ul>
        </nav>

        <transition
           :duration="{enter: 800, leave: 120 }"
            enter-active-class="animate__animated animate__fadeInLeft"
            enter-to-class="animate__animated animate__fadeInLeft"
            leave-active-class="animate__animated animate__fadeOutRight"
            leave-to-class="animate__animated animate__fadeOutRight"
            >

            <component :is="compName" :infoObj="infoObj"></component>

        </transition>
    </div>
</template>

<script>
import bookDetails from '@/pages/child/bookDetails.vue'
import play from '@/pages/child/play.vue'
import manuscript from '@/pages/child/manuscript.vue'

export default {
    props:{
        infoObj:{
            type: Object,
        }
    },
    name: "Details",
    components:{
    bookDetails,
    play,
    manuscript
    },
    data() {
      return {
        compName: "play",
        index: 1,
        flag: false,
      };
    },
    methods:{
        close(){
            this.$emit("detailsClose",this.flag)
        },
        addClick(i, cn) {
            this.index = i; // 设置索引值
            this.compName = cn; // 设置组件名称
        },
    }
}
</script>

<style lang="scss" scoped>
$color: #dc912c;
.nav{
    display: flex;
    justify-content: center;
    padding-top: 20px;
    ul{
        width: 340px;
        display: flex;
        justify-content: space-between;
        li{
            span{
                font-size: 22px;
            }
        }
        li:nth-child(2){
            span{
                font-size: 18px;
                padding: 0 12px;
                color: #999;
            }
            .active{
                color: #000;
                font-size: 20px;
            }
        }
    }
}
</style>